#ifndef MUSIC_H
#define MUSIC_H

#include <QDialog>
#include <QLabel>
#include <QListWidget>
#include <QTime>
#include <QTimer>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include "jwidget/jdialog.h"
#include <QDialog>
#include <QLineEdit>

#include <QtGui>
#include <QtCore>
#include <QTextCodec>
#include <QProcess>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#define musicdir "/music/"
#define musicPath "/music/"

class QSlider;
class QLabel;
class QListWidget;


class QComboBox;
class QDirModel;
class QItemSelectionModel;
class QModelIndex;
class QLabel;
class QPushButton;
class QString;

class Music : public JDialog
{
    Q_OBJECT

public:
    Music(QWidget *parent = 0);
    ~Music();
    void musicsettingonce();
	void keepVolUmeFixed();
    struct Tag_V1{
        char Header[3];
        char Title[30];
        char Artist[30];
        char Album[30];
        char Year[4];
        char Comment[30];
        char Cenre[1];
    }Mp3_ID3V1;

    struct TAG_V2{
        char Header[3];
        char Var[1];
        char Revision[1];
        char Flag[1];
        char Size[4];
    }Mp3_ID3V2;

    long int position;              //位置
    int bitrate;                    //比特率
    int sampling;                   //采样频率
    int sumnumber;                  //总的帧数

    QString str;                    //存放一些其他信息
    QString str1;                   //存放文件时间的字符串
    int first;                      //用来存放ID3V2的大小
    int second;                     //文件时间

    char temp[4];                   //用于存放XING头
    char temp1[4];                  //用于存放VBPI头
    char date[4];                   //some date

    int Timer_flag;                 //时间的标志位

private:
    QPushButton * down;
    QPushButton * up;
    QPushButton * setting;
    QPushButton * starMusic;
    QPushButton * musicclosebut;
    QPushButton * musicstopbut;
	QPushButton * volumeup;
	QPushButton * volumedown;
	
	
    QSlider  *slider ;
    QSlider  *runSlider ;
    QLabel  * soundLrc;
    QLabel  * volum;
    QLabel  * havedrun;
    QListWidget * listWidget;
    QTimer     *timerx;
    QTimer     *timer;

    QMovie *movie;
    QTimer     *giftimer;
    QPixmap * musicpix;
    QTime inittime;                 //初始化时间 0：0：0
    QTime addtime;                  //timeedit time
    QString seektime;               //存放时间的字符串
    QTimeEdit *starttime;           //开始时间
    QTimeEdit *overtime;            //结束时间（歌曲总时间）
    QLCDNumber *timertmp;

    QString fileName;
    QString filePath;
    QString setpath;
    QList<QString> musicList;
    QString command;
    QString backend;
    int nCount;
    int index;
    int currentsound;
    int gifcurren;
    FILE *fp;
    int choncehanv;
    int musiccount;
    float volume;

private slots:
        void slotStart();
        void slotUp();
        void slotDown();
        void slotOpen();
        void slotGetVol();
      //  void readInfo(QString file);
        void musicsetting();
        void scanMusicFun();
        void scanMusicFun0();
        void chosemusic();
        void slotShowTime();
        void startorstop();
        void musicclose();
        void musicstop();
		void volumup1dB();
		void volumdown1dB();
		

        void information();             //获取信息
        void fineframe();               //找枕头
        void obtaim_info();             //获取比特率和采样频率

        void readinfo();                //根据不同类型文件来获取文件时间
        void obtain_VBRtime();          //获取VBR文件的时间
        void obtain_CBPtime();          //获取CBP文件的时间
        void obtain_ID3V1();            //显示ID3V1信息，可要可不要。

        void obtain_ID3V2size();        //获取ID3V2的大小
        void displaytime();             //显示播放时间

        void someset();                 //定时器和进度条的初始设置

        void slottime();                //时间，进度条同步槽函数
        void slotShowgifTime();
};

#endif // MUSIC_H
